package IT06;

public class Student02 implements Comparable<Student02>{
    private String name;
    private int age;

    public Student02() {
    }

    public Student02(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(Student02 s) {
       // return 0;
        //return 1(正数);
        //return -1(负数);
        //按照年龄大小排序：
        int num = this.age-s.age;
        //年龄相同时，按照姓名的字母排序：
        int num2 = num==0?this.name.compareTo(s.name):num;
        return num2;
    }
}
